// pages/addressList/addressList.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pickerHidden: true,
    chosen: '',
    showadd: false,
    showedit:false,
    address:'',
    name:'',
    ipone:'',
   
    addlist:[
      {
        name:'小赵',
        ipone:'18814271534',
        address:'广东省广州市从化区中山大学南方学院',
        checked:true
      }
    ]
  },
  submit(e){
  console.log(e);
   let {name,ipone,address}=e.detail.value
   this.data.addlist=[...this.data.addlist,{name,ipone,address,checked:false}]
   wx.setStorageSync('addlist', this.data.addlist)
 
  
   this.setData({
    addlist:this.data.addlist,
    name:'',
    ipone:'',
    address:'',
    showadd: false
   })
  },
  chance(e){
  let index=e.currentTarget.dataset.index
  this.data.addlist.forEach(item=>{
    item.checked=false
  })
  this.data.addlist[index].checked=!this.data.addlist[index].checked
 this.setData(this.data)

  wx.setStorageSync('addlist', this.data.addlist)

  }, 

  showaddPopup() {
    this.setData({ showadd: true });

  },
  showeditPopup() {
    this.setData({ showedit: true });
    
  },

  onaddClose() {
    this.setData({ showadd: false });
  },
  oneditClose() {
    this.setData({ showedit: false });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    let temp=wx.getStorageSync('addlist')
   if (temp) {
    this.data.addlist=temp
  }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})